using System;

using MettleSystems.dashCommerce.Core;
using OpenNetCommerce.Localization;
using MettleSystems.dashCommerce.Store;
using SubSonic.Utilities;

namespace MettleSystems.dashCommerce.Web {
  public partial class receipt : MettleSystems.dashCommerce.Store.Web.SitePage {

    #region Member Variables

    private int transactionId = 0;
    private int orderId = 0;

    #endregion

    #region Page Events

    /// <summary>
    /// Handles the Load event of the Page control.
    /// </summary>
    /// <param name="sender">The source of the event.</param>
    /// <param name="e">The <see cref="T:System.EventArgs"/> instance containing the event data.</param>
    protected void Page_Load(object sender, EventArgs e) {
      try {
        transactionId = Utility.GetIntParameter("tid");
        orderId = Utility.GetIntParameter("oid");
        if (transactionId > 0) {
          Transaction transaction = new Transaction(transactionId);
          Order order = new OrderController().FetchOrder(transaction.OrderId, WebUtility.GetUserName());
          if (order.OrderId > 0) {
            lblReceipt.Text = order.ToHtml();
          }
        }
        if (orderId > 0) {
          Order order = new OrderController().FetchOrder(orderId, WebUtility.GetUserName());
          if (order.OrderId > 0) {
            lblReceipt.Text = order.ToHtml();
          }
        }
        //this.Title = string.Format(WebUtility.MainTitleTemplate, Master.SiteSettings.SiteName, LocalizationUtility.GetText("lblReceipt"));
      }
      catch (Exception ex) {
        Logger.Error(typeof(receipt).Name + ".Page_Load", ex);
        throw;
      }
    }

    #endregion

  }
}
